<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <div class="bar">
            <div class="bar_inner"></div>
        </div>
        <img :src="imgurl" alt="">
        <div>
            <button @click="punch" v-show="!isGameOver">给他一拳</button>
            <button v-show="isGameOver">重来</button>
        </div>
    </div>
    <script>
        new Vue({
            el:"#app",
            data(){
                return{
                    isGameOver:false,
                    life:100,
                    imgurl:'../img/2345_image_file_copy_1.jpg'
                }
            },
            methods:{
                punch(){
                    this.life-=10
                    if(this.life<=0){
                        this.isGameOver=true
                        this.imgurl='../img/2345_image_file_copy_2'
                    }
                },
                again(){
                    this.isGameOver=false
                    this.life=100
                    this.imgurl='../img/2345_image_file_copy_1.jpg'
                }
            },
            computed:{
                lifeFun(){
                    return this.life+'%'
                }
            }

        })
    </script>
</body>
</html>